#ifndef __TEST_MODE_H_
#define __TEST_MODE_H_

#include "stdbool.h"
#include "stdint.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct{
	uint16_t dataFlagU16;
	uint16_t funcTestPassCount;
	uint8_t sumCrcU8;
}TestSaveParam;	



typedef struct
{
	bool TestModeLockFlag;
	bool enableWorkFlag;
	int32_t enterTestWaitTime;
	bool testMeetingFlag;
	uint32_t testModeMeetingCount;
	bool testModeFlag;
	uint8_t funcTestFlag;

	uint32_t testTimeCount;
	TestSaveParam testSaveParam;
	
	uint32_t waitCount;
	uint16_t toolVpv;
	uint16_t connectVpv;
	
	bool workParamCorrectFlag;
	bool startDischargeFlag;
	bool startChargeFlag;
	
	uint16_t dischargeILoad;
	uint16_t dischargeVLoad;
	uint16_t dischargeDuty;
	
	uint16_t chargeBeforePvVol;
	uint16_t chargePvVol;
	uint16_t chargePvNVol;
	
	uint8_t sysParamTimeoutNum;
	uint8_t workParamTimeoutNum;
	
	uint8_t tryCount[19];
	uint8_t MID[5];
	uint8_t MCH;
	
	bool needSaveTestResult;
	
}TestMode;

extern TestMode testMode;	
	
void TestModeInit(void);
void EnterTestMode(void);
void TestModeHandshakeSucceed(void);
void TestModeStageSwitch(uint8_t* data);
void TestWriteSysParam(uint8_t *data);
void SwitchRequestWorkParm(void);
bool TestWorkParamCheck(uint8_t *data);
void TestWriteWorkParm(uint8_t *data);
void SwitchTestFuncResult(uint8_t result);
void TestModeSwitchDischargeStage(void);
void TestModeSwitchChargeStage(void);
void TestModeFirstMeeting(uint8_t *data);
void TestModeRxNbBindingResult(uint8_t *data);
bool EnableWork(void);
void TestModeSwitchSendWorkParamWriteResult(void);
	
bool IsTestEnd(void);
bool IsTestMode(void);
void TestModeProcess(void);

	
#ifdef __cplusplus
}
#endif
#endif

